home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #14 / Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO / prog_bas / msgbxcls.zip / MSGBOX.CLS < prev    next >
Text File  |  1996-01-08  |  4KB  |  141 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "clsMsgBox"
  6. Attribute VB_Creatable = False
  7. Attribute VB_Exposed = False
  8. '
  9. ' MsgBox Class
  10. ' Copyright ⌐ 1995-1996 Gregg Irwin. All Rights Reserved.
  11. '
  12. Option Explicit
  13. DefInt A-Z
  14.  
  15. #If Win16 Then
  16.     Private Declare Function MessageBox Lib "user" (ByVal HWnd As Integer, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Integer) As Integer
  17. #ElseIf Win32 Then
  18.     Private Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal HWnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
  19. #End If
  20.  
  21. '* PROPERTIES   *
  22. ' .HwndOwner
  23. ' .Message
  24. ' .StyleFlags
  25. ' .Title
  26.  
  27. '?? Add Helpfile and Context properties ??
  28. ' .HelpFile
  29. ' .Context
  30. '??
  31.  
  32. '* METHODS      *
  33. ' .ShowModal
  34.  
  35. Private mHwndOwner  As Long
  36. Private mMessage    As String
  37. Private mTitle      As String
  38. Private mStyle      As Long
  39.  
  40. '------------------------------------------------
  41. '-- PROPERTIES
  42. '------------------------------------------------
  43.  
  44. ' .HwndOwner
  45. Public Property Let HWndOwner(NewHwndOwner As Long)
  46.     mHwndOwner = NewHwndOwner
  47. End Property
  48.  
  49. Public Property Get HWndOwner() As Long
  50.     HWndOwner = mHwndOwner
  51. End Property
  52.  
  53.  
  54. ' .Message
  55. Public Property Let Message(NewMessage As String)
  56.     mMessage = NewMessage
  57. End Property
  58.  
  59. Public Property Get Message() As String
  60.     Message = mMessage
  61. End Property
  62.  
  63.  
  64. ' .StyleFlags
  65. Public Property Let Style(NewStyle As Long)
  66.     mStyle = NewStyle
  67. End Property
  68.  
  69. Public Property Get Style() As Long
  70.     Style = mStyle
  71. End Property
  72.  
  73.  
  74. ' .Title
  75. Public Property Let Title(NewTitle As String)
  76.     mTitle = NewTitle
  77. End Property
  78.  
  79. Public Property Get Title() As String
  80.     Title = mTitle
  81. End Property
  82.  
  83.  
  84. '------------------------------------------------
  85. '-- METHODS
  86. '------------------------------------------------
  87.  
  88. ' .ShowModal
  89. Public Function ShowModal(Optional Msg As Variant, Optional StyleFlags As Variant, _
  90.                          Optional BoxTitle As Variant, Optional HWnd As Variant) As Long
  91.     
  92.     Call FillMissingParmsFromProps(Msg, StyleFlags, BoxTitle, HWnd)
  93.  
  94.     '!! A Null Msg will cause a GPF so we have to check for null
  95.     '   string parameters and pass vbNullChar in their place.
  96.     If Len(Msg) Then
  97.         If Len(BoxTitle) Then
  98.             ShowModal = MessageBox(CLng(HWnd), CStr(Msg), CStr(BoxTitle), StyleFlags)
  99.         Else
  100.             ShowModal = MessageBox(CLng(HWnd), CStr(Msg), vbNullChar, StyleFlags)
  101.         End If
  102.     Else
  103.         If Len(BoxTitle) Then
  104.             ShowModal = MessageBox(CLng(HWnd), vbNullChar, CStr(BoxTitle), StyleFlags)
  105.         Else
  106.             ShowModal = MessageBox(CLng(HWnd), vbNullChar, vbNullChar, StyleFlags)
  107.         End If
  108.     End If
  109.  
  110. End Function
  111.  
  112.  
  113. '------------------------------------------------
  114. '-- INTERNAL SUPPORT PROCEDURES
  115. '------------------------------------------------
  116.  
  117. Private Sub FillMissingParmsFromProps(Optional Msg As Variant, Optional StyleFlags As Variant, _
  118.                                       Optional BoxTitle As Variant, Optional HWnd As Variant)
  119. '------------------------------------------------------
  120. '-- Fill any missing parameters with the value from
  121. '   their associated property.
  122. '------------------------------------------------------
  123.     
  124.     If IsMissing(Msg) Then
  125.         Msg = Me.Message
  126.     End If
  127.     
  128.     If IsMissing(StyleFlags) Then
  129.         StyleFlags = Me.Style
  130.     End If
  131.     
  132.     If IsMissing(BoxTitle) Then
  133.         BoxTitle = Me.Title
  134.     End If
  135.     
  136.     If IsMissing(HWnd) Then
  137.         HWnd = Me.HWndOwner
  138.     End If
  139.  
  140. End Sub
  141.